package days48;

import java.util.Scanner;

public class eight {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        String[]str=new String[n];
        for (int i = 0; i < n; i++) {
            str[i]=scanner.next();
        }
        if(judge1(str)&&judge2(str)){
            System.out.println("both");
        }else if(judge1(str)&&!judge2(str)){
            System.out.println("lexicographically");
        }else if(!judge1(str)&&judge2(str)){
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }

    }

    private static boolean judge1(String[] str)  {
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].compareTo(str[i+1])>0){
                return false;
            }
        }
        return true;
    }
    private static boolean judge2(String[] str) {
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].length()>str[i+1].length()){
                return false;
            }
        }
        return true;
    }

    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        if(a==b){
            System.out.println(a);
            return;
        }
        if(a>b){

                for (int i = b; i < a; i++) {
                    if(b*i%a==0){
                        System.out.println(b*i);
                        return;
                    }
            }
        }else {
            for (int i = a; i < b; i++) {
                if(a*i%b==0){
                    System.out.println(a*i);
                    return;
                }
            }
        }
    }
}
